<template>
  <div class="publish-con">
    <div style="background-color: white; width: 100%; padding-top: 5px">
      <a-space>
        <div>切换店铺</div>
        <a-select v-model="curShopId" style="width: 200px" @change="changeShop">
          <a-option v-for="(item, index) of shopList" :key="index" :value="item.id">{{ item.shopName }}</a-option>
        </a-select>
      </a-space>
    </div>

    <div class="top-tab">
      <a-tabs size="mini" v-model:active-key="curPage" @change="changeTab">
        <a-tab-pane v-for="item in tabList" :title="item.label" :key="item.key" />
      </a-tabs>
    </div>
    <div class="table-bottom table-gl-w">
      <div class="search-w">
        <FilterTable :max-num="5" :filterItem="filterItem" :isReset="true" @search="searchByVal"> </FilterTable>
      </div>
      <div class="table-gl-con">
        <TableWrap style="flex: 1" @refresh="getList">
          <template #headerLeft>
            <a-space>
              <a-button v-if="curPage != 'notFound'" class="gray-outline" @click="show('editTitleOrDesc')">修改标题和描述</a-button>
              <a-button v-if="curPage != 'notFound'" class="gray-outline" @click="show('keyWord')">设置关键词</a-button>
              <a-button v-if="curPage != 'notFound'" class="gray-outline" @click="show('goodsVisibility')">设置可见性</a-button>
              <a-button v-if="curPage != 'notFound'" class="gray-outline" @click="show('goodsVisualRange')">设置可见范围</a-button>
              <a-button v-if="curPage == 'notFound'" class="gray-outline" @click="batchSetData('mul', 'restore')">批量还原</a-button>
              <a-button v-if="curPage == 'notFound'" class="gray-outline" @click="batchSetData('mul', 'del')">批量删除</a-button>

              <a-button v-if="curPage == 'private,publish'" class="gray-outline" @click="setDataStatus('back')">退回</a-button>
              <a-button v-if="curPage == 'draft'" class="gray-outline" @click="setDataStatus('publish')">发布</a-button>
              <a-button class="gray-outline" @click="batchSetSalesman">设置运维</a-button>
            </a-space>
          </template>
          <template #tableBody>
            <a-table :data="tableData" size="mini" row-key="dataFromRestApi" v-model:selected-keys="ids" :row-selection="{ type: 'checkbox', showCheckedAll: true, onlyCurrent: false }" class="table-single-line" :loading="loading" :pagination="false" :scroll="{ x: '100%', y: '100%' }">
              <template #columns>
                <a-table-column title="序号" #cell="{ rowIndex }" :width="40">{{ rowIndex + 1 }}</a-table-column>
                <a-table-column title="图片" #cell="{ record }" :width="60">
                  <a-image @click="showBigImg(record)" width="40" height="40" fit="contain" :preview="false" :src="imgUrl(record)" />
                </a-table-column>
                <a-table-column title="ID" #cell="{ record }" :width="100">
                  <div class="link-id" @click="toJump(record)">
                    <span>{{ $extract(record, 'dataFromRestApi.id') }}</span>
                    <span class="my-icon-link">
                      <icon-link style="font-size: 16px" class="highlight" />
                    </span>
                  </div>
                </a-table-column>

                <a-table-column title="原URL" #cell="{ record }" :width="60">
                  <!-- <skuListPopover :list="record" :type="1" /> -->
                  <!-- {{ getSaleType(record) }} -->

                  <a-popover v-if="record.mallSourceUrl">
                    <icon-link style="font-size: 18px" class="highlight cursor" @click="jump(record)" />
                    <template #content>
                      <p>{{ record.mallSourceUrl }}</p>
                    </template>
                  </a-popover>
                </a-table-column>

                <a-table-column title="主体库存SKU" #cell="{ record }" :width="120">
                  <TextLimit position="top" :val="$extract(record, 'dataFromRestApi.sku') || '--'" />
                </a-table-column>
                <a-table-column title="分类" #cell="{ record }" :width="120">
                  <TextLimit position="top" :val="getCategoryName(record)" />
                </a-table-column>
                <a-table-column title="标题" #cell="{ record }" :width="120">
                  <TextLimit position="top" :val="$extract(record, 'dataFromRestApi.name')" />
                </a-table-column>
                <!-- <a-table-column title="简短描述" #cell="{ record }" :width="120">
                  <div v-if="$extract(record, 'dataFromRestApi.short_description')" v-html="$extract(record, 'dataFromRestApi.short_description')"></div>
                  <TextLimit v-if="$extract(record, 'dataFromRestApi.short_description')" position="top" :val="$extract(record, 'dataFromRestApi.short_description')"></TextLimit>
                  <div v-else>--</div>
                </a-table-column> -->
                <a-table-column title="关键词" #cell="{ record }" :width="120">
                  <TextLimit position="top" :val="getKeywordName(record) || '--'" />
                </a-table-column>
                <a-table-column title="产品属性" #cell="{ record }" :width="80">
                  <productPre :info="record" />
                </a-table-column>
                <a-table-column v-if="curPage == 'private,publish'" title="可见性" #cell="{ record }" :width="80"> {{ visiableMap[$extract(record, 'dataFromRestApi.status')] }} </a-table-column>
                <a-table-column title="可见范围" #cell="{ record }" :width="80">
                  {{ visiableRangeMap[$extract(record, 'dataFromRestApi.catalog_visibility')] || $extract(record, 'dataFromRestApi.catalog_visibility') }}
                </a-table-column>
                <a-table-column title="类型" #cell="{ record }" :width="80">
                  {{ $extract(record, 'dataFromRestApi.type') == 'simple' ? '单体' : '变体' }}
                </a-table-column>
                <a-table-column title="变体库存SKU" #cell="{ record }" :width="100">
                  <skuListPopover :data="record" />
                </a-table-column>
                <a-table-column title="售价方式" #cell="{ record }" :width="80">
                  {{ showSaleType(record) }}
                </a-table-column>
                <a-table-column title="起订量" #cell="{ record }" :width="80">
                  {{ getStartNum(record) }}
                </a-table-column>
                <a-table-column title="售价" #cell="{ record }" :width="140">
                  <div v-if="showSaleType(record) == '一口价'"></div>
                  <div v-else>
                    <div v-for="(item, index) of getMetaDataArr(record)" :key="index">
                      <span>{{ item.quantity }}</span>
                      <span>-</span>
                      <span>{{ item.endNum }}</span>
                      <span>：</span>
                      <span>${{ item.price }}</span>
                    </div>
                  </div>
                  <!-- {{ $extract(record, 'dataFromRestApi.sale_price') || '--' }} -->
                </a-table-column>
                <a-table-column title="运营" #cell="{ record }" :width="80">
                  {{ record.operationUserName ? record.operationUserName : '--' }}
                </a-table-column>
                <a-table-column title="创建时间" #cell="{ record }" :width="120">
                  {{ $extract(record, 'dataFromRestApi.date_created') }}
                </a-table-column>
                <a-table-column title="操作" #cell="{ record }" :width="80" fixed="right">
                  <a-space>
                    <a-button v-if="curPage == 'private,publish'" type="text" @click="detail(record)">详情</a-button>
                    <a-button v-if="curPage == 'draft'" type="text" @click="edit(record)">编辑</a-button>
                    <a-button v-if="curPage == 'draft'" type="text" @click="del(record)" style="color: red">删除</a-button>
                    <a-button v-if="curPage == 'notFound'" type="text" @click="batchSetData('single', 'restore', record)">还原</a-button>
                    <a-button v-if="curPage == 'notFound'" type="text" @click="batchSetData('single', 'del', record)" style="color: red">删除</a-button>
                  </a-space>
                </a-table-column>
              </template>
            </a-table>
          </template>
        </TableWrap>
        <div class="pagination-footer">
          <a-pagination size="mini" :page-size-options="[20, 50, 100, 200, 500]" show-total show-page-size :total="pageNation.total" :default-page-size="pageNation.pageSize" :current="pageNation.pageNum" style="float: right" @page-size-change="sizeChange" @change="changePage" />
        </div>
      </div>
    </div>
  </div>
  <!-- 新建商品 -->
  <!-- <createShop v-if="showCreateShopModal" v-model="showCreateShopModal" @save="resetAndRefreshList" /> -->
  <!-- 批量修改标题或者描述 -->
  <batchEditTitleOrDesc v-if="showBatchEditTitleOrDescModal" v-model="showBatchEditTitleOrDescModal" :shopId="curShopId" :ids="ids" @save="resetAndRefreshList" />
  <!-- 批量修改关键词 -->
  <batchSetKeyword v-if="showBatchSetKeywordModal" v-model="showBatchSetKeywordModal" :ids="ids" :shopId="curShopId" @save="resetAndRefreshList" />
  <!-- 批量设置可见性和可见范围 -->
  <batchSetVisibleOrRange v-if="showBatchSetVisibleOrRangeModal" v-model="showBatchSetVisibleOrRangeModal" :type="batchSetVisibleOrRangeType" :shopId="curShopId" :ids="ids" @save="resetAndRefreshList" />
  <!-- 图片查看 -->
  <a-image-preview-group v-model:visible="visible" v-model:current="current" infinite :srcList="previewList" />
  <!-- 详情 -->
  <detailInfo v-if="showDetailInfoModal" v-model="showDetailInfoModal" :id="id" />
  <!-- 批量设置运营 -->
  <batchSetSalesMan v-if="showBatchSetSalesManModal" v-model="showBatchSetSalesManModal" :list="selectRow" @save="resetAndRefreshList" />
</template>

<script lang="ts" setup>
  import { computed, ref, onMounted } from 'vue'
  import { listAllCategoryTreeByShopId, saleRollPage, saleDeleteByIdList, tagRollPage, batchProduct, batchDeleteProduct, listAllUserWordPressShop } from '@/api/product'
  import { getOrganizesUser } from '@/api/system'
  import { Message, Modal } from '@arco-design/web-vue'
  import { useRouter } from 'vue-router'
  import FilterTable from '@/components/TableFilter.vue'
  import TableWrap from '@/components/TableWrap.vue'
  import skuListPopover from './components/skuListPopover.vue'
  import productPre from './components/productPre.vue'
  // import createShop from './components/createShop.vue'
  import batchEditTitleOrDesc from './components/batchEditTitleOrDesc.vue'
  import batchSetKeyword from './components/batchSetKeyword.vue'
  import batchSetVisibleOrRange from './components/batchSetVisibleOrRange.vue'
  import detailInfo from './detailInfo.vue'
  import batchSetSalesMan from './components/batchSetSalesMan.vue'
  const visiableMap = {
    publish: '公开',
    private: '私密',
  }
  const visiableRangeMap = {
    visible: '商店页和搜索结果页',
    catalog: '仅商店页',
    search: '仅搜索结果页',
    hidden: '隐藏',
  }
  const route = useRouter()
  let loading = ref(false)
  let visible = ref(false)
  let showDetailInfoModal = ref(false)
  let showBatchSetSalesManModal = ref(false)
  let current = ref(0)
  let shopList: any = ref([])
  let selectRow: any = ref([])
  let curShopId = ref('')
  let id = ref('')
  let previewList = ref([])
  // let showCreateShopModal = ref(false)
  let showBatchEditTitleOrDescModal = ref(false)
  let showBatchSetKeywordModal = ref(false)
  let showBatchSetVisibleOrRangeModal = ref(false)
  let ids = ref([])
  let batchSetVisibleOrRangeType = ref('')
  let curPage = ref('private,publish')
  let searchValue: any = ref({})
  let pageNation = ref({ total: 0, pageNum: 1, pageSize: 20 })
  let tabList = ref([
    { label: '已发布', num: '231', key: 'private,publish' },
    { label: '草稿', num: '1', key: 'draft' },
    { label: '回收站', num: '5', key: 'notFound' },
  ])
  let tableData = ref([{}])
  const filterItem: any = ref([
    {
      type: 'input_keyword',
      key: 'name',
      keyItems: [
        { label: '标题', value: 'name' },
        { label: '简短描述', value: 'description' },
      ],
      keyWidth: '100',
      value: ref(),
      placeholder: '请输入',
      label: '标题',
      width: 180,
    },
    {
      type: 'input_keyword_type',
      key: 'dataFromRestApi.sku',
      keyItems: [
        { label: '主体库存SKU', value: 'dataFromRestApi.sku' },
        { label: '变体库存SKU', value: 'variationList.dataFromRestApi.sku' },
      ],
      keyWidth: '130',
      value: ref(),
      placeholder: '请输入',
      label: '主体库存SKU',
      width: 200,
      isMultiple: true,
    },
    {
      key: 'operationUserIdList',
      label: '运营',
      value: ref(),
      type: 'select',
      width: 180,
      optionItems: [],
      attrs: {
        'allow-clear': true,
      },
    },
    {
      key: 'status',
      label: '可见性',
      value: ref(),
      type: 'select',
      width: 110,
      optionItems: [
        { label: '公开', value: 'publish' },
        { label: '私密', value: 'private' },
      ],
      attrs: {
        'allow-clear': true,
        disabled: curPage.value == 'private,publish' ? false : true,
      },
    },
    {
      key: 'catalogVisibilityList',
      label: '可见范围',
      value: ref(),
      type: 'select',
      width: 110,
      optionItems: [
        { label: '可见', value: 'visible' },
        { label: '搜索', value: 'search' },
        { label: '隐藏', value: 'hidden' },
      ],
    },
    {
      type: 'cascader',
      key: 'categoryIdList',
      optionItems: [],
      keyWidth: '120',
      value: ref(),
      placeholder: '商品分类',
      label: '类目',
      width: '100%',
      isMultiple: true,
    },
    {
      key: 'tagIdList',
      label: '标签',
      value: ref(),
      type: 'select',
      width: '100%',
      optionItems: [],
    },
    // {
    //   key: 'taskType',
    //   label: '类型',
    //   value: ref(),
    //   type: 'select',
    //   width: '100%',
    //   optionItems: [
    //     { label: '单体', value: '单体' },
    //     { label: '变体', value: '变体' },
    //   ],
    //   attrs: {
    //     'allow-clear': true,
    //   },
    // },
    // {
    //   key: 'taskType',
    //   label: '产品来源',
    //   value: ref(),
    //   type: 'select',
    //   width: '100%',
    //   optionItems: [
    //     { label: '自营', value: '自营' },
    //     { label: '1688', value: '1688' },
    //     { label: 'Amazon', value: 'Amazon' },
    //     { label: '梅陇在线', value: '梅陇在线' },
    //     { label: '其他', value: '其他' },
    //   ],
    // },
    {
      key: 'metaDataList',
      label: '售价方式',
      value: ref(),
      type: 'select',
      width: '100%',
      optionItems: [
        { label: '一口价', value: 'disable' },
        { label: '阶梯价', value: 'override' },
      ],
    },
    {
      type: 'keyword_date_range',
      key: 'dataFromRestApiDateCreated',
      keyItems: [{ label: '创建时间', value: 'dataFromRestApiDateCreated' }],
      keyWidth: '110',
      label: '创建时间',
      value: ref(),
      width: 300,
    },
  ])

  const setNewTreeData = (data: any) => {
    data.forEach((item: any) => {
      item.name = item.dataFromRestApi.name
      item.value = item.dataFromRestApi.id
      if (!item.children[0]) item.children = null
      if (item.children) {
        setNewTreeData(item.children)
      }
    })
  }

  // 获取类目
  const getCategory = async () => {
    const res: any = await listAllCategoryTreeByShopId({ shopId: curShopId.value })
    let arr = res.data
    setNewTreeData(arr)
    filterItem.value[5].optionItems = arr
  }

  // 获取标签
  const getTagList = async () => {
    const res: any = await tagRollPage({ shopIdList: [curShopId.value], pageSize: 9999999 })
    let arr = res?.data?.list || []
    filterItem.value[6].optionItems = arr.map((e: any) => {
      e.label = e.dataFromRestApi.name
      e.value = e.id
      return e
    })
  }

  // 图片
  const imgUrl = (info: any) => {
    let arr = info.dataFromRestApi?.images || []
    return arr[0]?.src || ''
  }

  // 显示弹框
  const show = (type: string) => {
    if (!ids.value[0]) {
      return Message.error('请选择要设置的数据')
    }

    console.log(ids.value)

    switch (type) {
      case 'editTitleOrDesc':
        showBatchEditTitleOrDescModal.value = true
        break
      case 'keyWord':
        showBatchSetKeywordModal.value = true
        break
      case 'goodsVisibility':
        batchSetVisibleOrRangeType.value = 'goodsVisibility'
        showBatchSetVisibleOrRangeModal.value = true
        break
      case 'goodsVisualRange':
        batchSetVisibleOrRangeType.value = 'goodsVisualRange'
        showBatchSetVisibleOrRangeModal.value = true
        break
    }
  }

  const resetAndRefreshList = () => {
    pageNation.value.pageNum = 1
    ids.value = []
    getList()
  }

  // 编辑刊登
  const edit = (info: any) => {
    route.push({
      path: '/wordPress/onlineProduct/editOnlineProductIndex',
      query: {
        id: info.id,
      },
    })
  }
  const detail = (info: any) => {
    // route.push({
    //   path: '/wordPress/onlineProduct/detailInfo',
    //   query: {
    //     id: info.id,
    //   },
    // })
    id.value = info.id
    showDetailInfoModal.value = true
  }

  const getCategoryName = (info: any) => {
    let arr = info.dataFromRestApi?.categories || []
    return arr.map((e: any) => e.name).join(',')
  }

  const getKeywordName = (info: any) => {
    let arr = info.dataFromRestApi?.tags || []
    return arr.map((e: any) => e.name).join(',')
  }

  const del = (data: any) => {
    Modal.error({
      title: '删除',
      content: '请再次确认是否要删除商品',
      titleAlign: 'start',
      cancelText: '取消',
      hideCancel: false,
      onOk: async () => {
        let params = {
          force: false,
          idList: [data.dataFromRestApi.id],
          shopId: data.shopId,
        }
        const res: any = await batchDeleteProduct(params)
        if (res.code == 'SUCCESS') {
          Message.success('删除成功。')
          getList()
        }
      },
    })
  }

  // 搜索
  const searchByVal = (info: any) => {
    searchValue.value = info
    getList()
  }
  // 分页
  const changePage = (val: number) => {
    pageNation.value.pageNum = val
    getList()
  }

  const sizeChange = (val: number) => {
    pageNation.value.pageNum = 1
    pageNation.value.pageSize = val
    getList()
  }

  const getList = async () => {
    let params: any = {
      ...searchValue.value,
      needCount: true,
      shopIdList: [curShopId.value],
      pageNum: pageNation.value.pageNum,
      pageSize: pageNation.value.pageSize,
      statusList: curPage.value.split(','),
    }

    if (params.metaDataList) {
      params.metaDataList = [{ key: 'wpcpq_enable', value: searchValue.value.metaDataList }]
    }

    if (params.catalogVisibilityList) {
      params.catalogVisibilityList = params.catalogVisibilityList.split(',')
    } else {
      delete params.catalogVisibilityList
    }
    if (params.categoryIdList) {
      params.categoryIdList = params.categoryIdList.split(',')
    } else {
      delete params.categoryIdList
    }
    if (params.tagIdList) {
      params.tagIdList = params.tagIdList.toString().split(',')
    } else {
      delete params.tagIdList
    }
    if (params.operationUserIdList) {
      params.operationUserIdList = params.operationUserIdList.split(',')
    } else {
      delete params.operationUserIdList
    }

    if (params.startDate) {
      params.startDate = `${params.startDate} 00:00:00`
      params.endDate = `${params.endDate} 23:59:59`
    } else {
      delete params.startDate
      delete params.endDate
    }

    // 如果有所条件有的话直接用搜索条件里面的
    if (params.status) params.statusList = params.status.split(',')
    loading.value = true
    const res: any = await saleRollPage(params)
    loading.value = false
    ids.value = [] // 清空选项
    pageNation.value.total = res.data.total || []
    let resultArr = res.data.list || []
    tableData.value = resultArr.map((e: any) => {
      e.dataFromRestApi.yfnCustomId = e.id
      return e
    })
  }

  const showSaleType = (data: any) => {
    let arr = data?.dataFromRestApi?.meta_data || []
    if (arr[0]) {
      let item = arr.find((e: any) => e.key == 'wpcpq_enable')
      return item && item.value == 'disable' ? '一口价' : '阶梯价'
    } else {
      return '--'
    }
  }

  const getMetaDataArr = (data: any) => {
    let resArr = []
    let arr = data?.dataFromRestApi?.meta_data || []
    if (arr[0]) {
      let item = arr.find((e: any) => e.key == 'wpcpq_prices')?.value || {}
      if (item.length > 3) resArr = JSON.parse(item).tiers
    }
    return resArr
  }

  const getShopLsit = async () => {
    let params = {
      pageSize: 999999,
      platform: 'wooCommerce',
    }
    const res: any = await listAllUserWordPressShop(params)
    shopList.value = res.data || []
    curShopId.value = shopList.value[0].id
  }

  const showBigImg = (data: any) => {
    let arr = data?.dataFromRestApi?.images || []
    previewList.value = arr.map((e: any) => e.src)
    current.value = 0
    visible.value = true
  }

  const changeShop = async () => {
    await getList()
    await getCategory()
    await getTagList()
  }

  // 批量操作回收站
  const batchSetData = (isMul: string, type: string, data?: any) => {
    if (isMul == 'mul' && !ids.value[0]) return Message.error(`请选择要${type == 'del' ? '删除' : '还原'}的数据`)

    Modal[type == 'del' ? 'error' : 'info']({
      title: '提示',
      content: `请再次确认是否要${type == 'del' ? '删除' : '还原'}`,
      titleAlign: 'start',
      cancelText: '取消',
      hideCancel: false,
      onOk: async () => {
        let res: any = null
        if (type == 'del') {
          let params = {
            force: true,
            idList: isMul == 'single' ? [data.dataFromRestApi.id] : ids.value.map((e: any) => e.id),
            shopId: curShopId.value,
          }
          res = await batchDeleteProduct(params)
          Message.success('删除成功。')
        } else {
          let params: any = {
            param: {
              update: [],
            },
            shopId: curShopId.value,
          }
          if (isMul == 'single') {
            params.param.update.push({
              id: data.dataFromRestApi.id,
              status: 'publish',
            })
          } else {
            ids.value.forEach((e: any) => {
              params.param.update.push({
                id: e.id,
                status: 'publish',
              })
            })
          }
          res = await batchProduct(params)
          Message.success('还原成功。当前操作不是立即生效，请等待几分钟后刷新页面')
        }

        if (res.code == 'SUCCESS') {
          getList()
          ids.value = []
        }
      },
    })
  }
  const setDataStatus = (type: string) => {
    if (!ids.value[0]) return Message.error(`请选择要${type == 'back' ? '退回' : '发布'}的数据`)

    Modal[type == 'back' ? 'error' : 'info']({
      title: '提示',
      content: `请再次确认是否要${type == 'back' ? '退回' : '发布'}`,
      titleAlign: 'start',
      cancelText: '取消',
      hideCancel: false,
      onOk: async () => {
        let res: any = null
        let params: any = {
          param: {
            update: [],
          },
          shopId: curShopId.value,
        }

        ids.value.forEach((e: any) => {
          params.param.update.push({
            id: e.id,
            status: type == 'back' ? 'draft' : 'publish',
          })
        })

        res = await batchProduct(params)
        Message.success(`${type == 'back' ? '退回成功' : '发布成功'}。当前操作不是立即生效，请等待几分钟后刷新页面`)

        if (res.code == 'SUCCESS') {
          getList()
          ids.value = []
        }
      },
    })
  }

  const toJump = (data: any) => {
    let a = document.createElement('a')
    a.target = '_blank'
    a.href = data.dataFromRestApi?.permalink
    a.click()
  }
  const jump = (data: any) => {
    let a = document.createElement('a')
    a.target = '_blank'
    a.href = data.mallSourceUrl
    a.click()
  }

  const getPriceNum = (data: any) => {
    let arr = data?.dataFromRestApi?.meta_data || []
    if (arr[0]) {
      let item = arr.find((e: any) => e.key == 'min_quantity')
      return item.value
    } else {
      return '--'
    }
  }

  const getStartNum = (data: any) => {
    let meta_data_arr = data?.dataFromRestApi?.meta_data || []
    let index = meta_data_arr.findIndex((e: any) => e.key == 'wpcpq_enable' && e.value == 'disable')
    if (index != -1) {
      let item = meta_data_arr.find((e: any) => e.key == 'min_quantity')
      if (item) return item.value
    }
    return ''
  }

  const changeTab = (val: string) => {
    sizeChange(20)
    console.log(val)
    if (val == 'private,publish') {
      filterItem.value[3].type = 'select'
    } else {
      filterItem.value[3].type = '11'
    }
  }

  const getUSerList = async () => {
    let params = {
      depart: false,
      pageNum: 1,
      pageSize: 100000,
    }
    const res: any = await getOrganizesUser(params)
    let arr = res?.data?.records || []
    filterItem.value[2].optionItems = arr.map((e: any) => {
      e.label = e.userName
      e.value = e.id
      return e
    })
    // userList.value = res?.data?.records || []
  }

  const batchSetSalesman = () => {
    selectRow.value = []
    if (!ids.value[0]) return Message.error('请选择要设置运维的数据')
    ids.value.forEach((e: any) => {
      let item = tableData.value.find((el: any) => e.id == el.dataFromRestApi.id)
      if (item) selectRow.value.push(item)
    })
    showBatchSetSalesManModal.value = true
  }

  onMounted(async () => {
    getUSerList()
    await getShopLsit()
    await getList()
    await getCategory()
    await getTagList()
  })
</script>

<style lang="less" scoped>
  .publish-con {
    .top-tab {
      background-color: white;
    }
    .table-bottom {
      height: calc(100vh - @menuAndTabHeight - 38px);
      .search-w {
        width: 100%;
        background-color: white;
        padding: 10px 0 1px 0;
        box-sizing: border-box;
      }
    }
  }

  .link-id {
    .my-icon-link {
      display: none;
    }
    &:hover {
      cursor: pointer;
      .my-icon-link {
        display: inline-block;
      }
    }
  }
</style>
